package com.zj.web.bean;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.zj.model.Address;
import com.zj.model.Orderdetail;
import com.zj.model.Product;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)  // 新增：忽略未知字段，避免字段不匹配导致反序列化失败
public class OrdersDTO {
    @JsonSerialize(using = ToStringSerializer.class)
    private Long orderId; // 订单ID
    private Long userId; // 用户ID
    private Long addressId; // 地址ID
    private Date orderTime; // 订单时间
    private Integer orderStatus; // 订单状态

    private Double totalPrice; // 订单总金额
    private Product product=new Product();
    private Address address=new Address();
    private Orderdetail orderdetail=new Orderdetail();

    @JsonIgnore
    private String email;

    public OrdersDTO(Long orderId, Long userId, Long addressId, Date orderTime, Integer orderStatus, Double totalPrice,  String email) {
        this.orderId = orderId;
        this.userId = userId;
        this.addressId = addressId;
        this.orderTime = orderTime;
        this.orderStatus = orderStatus;
        this.totalPrice = totalPrice;
        this.email = email;
    }

}
